<template>
    <view>
        <!-- <web-view :src="mainStore.h5AuthUrl"></web-view> -->
        <web-view :src="mainStore.h5AuthUrl">
            <cover-view class="coverBtn" @click.native="BackBtn">
                <cover-image class="cover-image" :src="staticImg('BackWhite.png')"></cover-image>
            </cover-view>
        </web-view>
    </view>
</template>

<script setup>
    import { ref, computed, watch, nextTick, onUnmounted } from 'vue';
    import { onLoad, onShow, onReady } from '@dcloudio/uni-app';
    import { useMainStore } from '@/stores/index';
    import Http from '@/utils/request.js';
    import {
        toUrl,
        toLogin,
        Toast,
        formatter,
        tampToDate,
        staticImg,
        imgUrls,
        showLoading,
        hideLoading,
        toRect,
        toPage,
        getFileExtension,
        previewFile,
        Back,
    } from '@/utils/utils.js';
    const mainStore = useMainStore();
    const httpUrls = ref('');
    onLoad((opt) => {
        if (opt.Type == 1) {
            getPactStatus();
        } else {
            // getOrderPactStatus();
        }
    });

    const BackBtn = () => {
        uni.navigateBack({
            delta: 1,
        });
    };

    // 实名认证
    const getPactStatus = () => {
        Http.get({
            url: '/order/getPactStatus',
        }).then((res) => {
            if (res.code != 0) return Toast(res.msg);
            const result = res.data;
            if (result == 1) {
                Back();
            } else {
                setTimeout(() => {
                    getPactStatus();
                }, 1000);
            }
        });
    };

    // 签约
    const getOrderPactStatus = () => {
        Http.get({
            url: '/order/getOrderPactStatus',
            data: {
                orderId: mainStore.orderId,
            },
        }).then((res) => {
            if (res.code != 0) return Toast(res.msg);
            const result = res.data;
            if (result == 1) {
                Back();
            } else {
                setTimeout(() => {
                    getOrderPactStatus();
                }, 1000);
            }
        });
    };
</script>

<style lang="scss">
    cover-view,
    cover-image {
        visibility: visible !important;
        z-index: 99999;
    }
    .coverBtn {
        width: 100rpx;
        height: 100rpx;
        background-color: #0083ff;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        position: fixed;
        bottom: 100rpx;
        left: 20rpx;
        z-index: 999999;
        overflow: hidden;
        pointer-events: auto;
        transform: translateZ(0);
        .cover-image {
            width: 48rpx;
            height: 48rpx;
            pointer-events: auto;
            transform: translateZ(0);
            will-change: transform;
        }
    }
</style>
